@extends('backend::common.common_right')
@section('content')
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <button data-toggle="modal" href="{{url('backend/catcreate',['id'=>0,'type'=>$type])}}" data-target="#myModal"
                                type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
                            添加分类
                        </button>
                    </div>
                    <div class="ibox-content">
                        {{--模态框--}}
                        <div class="">
                            <div class="modal fade" id="myModal" aria-labelledby="myModelLabel" tabindex="-1"
                                 role="dialog" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content animated bounceInRight">

                                    </div>
                                </div>
                            </div>
                        </div>
                        {{--模态框--}}
                        <table class="table table-bordered">
                            <thead>
                                <th>分类ID</th>
                                <th>分类名称</th>
                                <th>等级</th>
                                <th>是否展示</th>
                                <th>操作</th>
                            </thead>
                            @isset($cats[2])
                            @foreach ($cats[2] as $c2)
                                <tr>
                                    <td>{{ $c2->id }}</td>
                                    <td><a onclick="catshow({{$c2->id}})" href='javascript:;'>{{ $c2->catname }}</a></td>
                                    <td>二级</td>
                                    <td class="center">{{ $c2->is_show }}</td>
                                    <td class="center">
                                        <a data-toggle="modal" href="{{url('backend/catcreate',['id'=>$c2->id,'type'=>$type])}}" data-target="#myModal" data-toggle="modal" data-target="#myModal"><i class="fa fa-pencil"></i>编辑</a>
                                    </td>
                                </tr>
                                @isset($cats[3])
                                    @foreach ($cats[3] as $c3)
                                        @if ($c3->father_id == $c2->id)
                                            <tr class="catshow catshow{{$c2->id}}">
                                                <td class="text-center">{{ $c3->id }}</td>
                                                <td class="text-center">{{ $c3->catname }}</td>
                                                <td class="text-center">三级</td>
                                                <td class="text-center">{{ $c3->is_show }}</td>
                                                <td class="text-center">
                                                <a data-toggle="modal" href="{{url('backend/catcreate',['id'=>$c3->id,'type'=>$type])}}" data-target="#myModal"  data-toggle="modal" data-target="#myModal"><i class="fa fa-pencil"></i>编辑</a>
                                                </td>
                                            </tr>
                                        @endif
                                    @endforeach
                                @endisset
                            @endforeach
                            @endisset
                        </table>
                    </div>

                </div>
            </div>
        </div>
    </div>
    <script>
        $('.catshow').hide();
        var catshow = function (id) {
            var display =$('.catshow'+id).css('display');
            if(display == 'none'){
                $('.catshow'+id).show();
            }else{
                $('.catshow'+id).hide();
            }
        }

    </script>
@endsection

